﻿using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PlatformerCS
{
    /// <summary>
    /// Handle background graphic.
    /// </summary>
    class Terrain
    {
        ContentManager content;
        private Texture2D[] textures;
        int index;

        public Terrain(ContentManager content)
        {
            textures = new Texture2D[1];
            this.content = content;
            SetBackground(0);
        }

        /// <summary>
        /// Sets the background.
        /// </summary>
        /// <param name="n">The index of the textures array.</param>
        public void SetBackground(int n)
        {
            index = n;
            if (textures[n] == null)
                textures[n] = content.Load<Texture2D>("Backgrounds/background" + n);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textures[index], new Vector2(-600, 0), Color.White);
        }
    }
}
